#include "StdAfx.h"
#include "LasPoint.h"

#include "LasHeader.h"

CLasPoint::CLasPoint()
{
	m_iPointType = 100;
}

CLasPoint::~CLasPoint(void)
{
}

bool CLasPoint::ReadPoint(const void *lpBuffer)
{
	const unsigned char *pCurrent = (const unsigned char *)lpBuffer;
	m_RawX = *(long *)pCurrent;
	pCurrent += sizeof(m_RawX);
	m_RawY = *(long *)pCurrent;
	pCurrent += sizeof(m_RawY);
	m_RawZ = *(long *)pCurrent;
	pCurrent += sizeof(m_RawZ);
	m_Intensity = *(long *)pCurrent;
	pCurrent += sizeof(m_Intensity);

	return true;
}

void CLasPoint::SetHeader(const CLasHeader *pHeader)
{
	m_iPointType = pHeader->GetPointType();
	m_dXScaleFactor = pHeader->GetXScaleFactor();
	m_dYScaleFactor = pHeader->GetYScaleFactor();
	m_dZScaleFactor = pHeader->GetZScaleFactor();
	m_dXOffset = pHeader->GetXOffset();
	m_dYOffset = pHeader->GetYOffset();
	m_dZOffset = pHeader->GetZOffset();
	
}

long CLasPoint::GetRawX() const
{
	return m_RawX;
}

long CLasPoint::GetRawY() const
{
	return m_RawY;
}

long CLasPoint::GetRawZ() const
{
	return m_RawZ;
}

double CLasPoint::GetCoordinateX() const
{
	return m_RawX * m_dXScaleFactor + m_dXOffset;
}

double CLasPoint::GetCoordinateY() const
{
	return m_RawY * m_dYScaleFactor + m_dYOffset;
}

double CLasPoint::GetCoordinateZ() const
{
	return m_RawZ * m_dZScaleFactor + m_dZOffset;
}
